package org.example.web.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.time.LocalDateTime;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public class InspectDto {
    private String id;
    private String params;
    private String applicationName;
    private String applicationContextClass;
    private String controllerClass;
    private String controller;
    private String applicationContext;
    private String parentContext;
    private String beanFactory;
    private String parentBeanFactory;
    private LocalDateTime currentTime;
    private Long startupDate;

    public String getId() {
        return this.id;
    }


    public void setId(String id) {
        this.id = id;
    }


    public String getApplicationName() {
        return this.applicationName;
    }


    public void setApplicationName(String applicationName) {
        this.applicationName = applicationName;
    }


    public String getParams() {
        return this.params;
    }


    public void setParams(String params) {
        this.params = params;
    }


    public String getApplicationContextClass() {
        return this.applicationContextClass;
    }


    public void setApplicationContextClass(Class applicationContextClass) {
        this.applicationContextClass = clazz(applicationContextClass);
    }


    public String getControllerClass() {
        return this.controllerClass;
    }


    public void setControllerClass(Class controllerClass) {
        this.controllerClass = clazz(controllerClass);
    }


    public String getController() {
        return this.controller;
    }


    public void setController(Object controller) {
        this.controller = s(controller);
    }


    public String getApplicationContext() {
        return this.applicationContext;
    }


    public void setApplicationContext(Object applicationContext) {
        this.applicationContext = s(applicationContext);
    }


    public String getParentContext() {
        return this.parentContext;
    }


    public void setParentContext(Object parentContext) {
        this.parentContext = s(parentContext);
    }


    public String getBeanFactory() {
        return this.beanFactory;
    }


    public void setBeanFactory(Object beanFactory) {
        this.beanFactory = s(beanFactory);
    }


    public String getParentBeanFactory() {
        return this.parentBeanFactory;
    }


    public void setParentBeanFactory(Object parentBeanFactory) {
        this.parentBeanFactory = s(parentBeanFactory);
    }


    public LocalDateTime getCurrentTime() {
        return this.currentTime;
    }


    public void setCurrentTime(LocalDateTime currentTime) {
        this.currentTime = currentTime;
    }


    public Long getStartupDate() {
        return this.startupDate;
    }


    public void setStartupDate(Long startupDate) {
        this.startupDate = startupDate;
    }


    private String clazz(Class clazz) {
        return clazz.getClassLoader().toString() + ":" + clazz.toString() + "@" + clazz.hashCode();
    }


    private String s(Object o) {
        return (o != null) ? o.toString() : "";
    }
}
